﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="chatrooms_list.aspx.cs" Inherits="CL.Admin.admin.immanage.chatrooms_list" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,initial-scale=1.0,user-scalable=no" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <title>IM聊天室列表</title>
    <link href="../../scripts/artdialog/ui-dialog.css" rel="stylesheet" type="text/css" />
    <link href="../skin/default/style.css" rel="stylesheet" type="text/css" />
    <link href="../../css/pagination.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="../../scripts/jquery/jquery-1.11.2.min.js"></script>
    <script type="text/javascript" src="../../scripts/artdialog/dialog-plus-min.js"></script>
    <script type="text/javascript" charset="utf-8" src="../js/laymain.js"></script>
    <script type="text/javascript" charset="utf-8" src="../js/common.js"></script>
</head>
<body class="mainbody">
    <form id="form1" runat="server">
        <!--导航栏-->
        <div class="location">
            <a href="javascript:history.back(-1);" class="back"><i></i><span>返回上一页</span></a>
            <a href="../center.aspx" class="home"><i></i><span>首页</span></a>
            <i class="arrow"></i>
            <span>IM聊天室列表</span>
        </div>
        <!--/导航栏-->

        <!--列表-->
        <div class="table-container">
            <asp:Repeater ID="rptList" runat="server">
                <HeaderTemplate>
                    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="ltable">
                        <tr>
                            <th>聊天室ID</th>
                            <th>聊天室名称</th>
                            <th>拥有者</th>
                            <th>加入人数</th>
                            <th>操作</th>
                        </tr>
                </HeaderTemplate>
                <ItemTemplate>
                    <tr>
                        <td align="center"><%# Eval("id") %></td>
                        <td align="center"><%# Eval("name") %></td>
                        <td align="center"><%# Eval("owner") %></td>
                        <td align="center"><%# Eval("affiliations_count") %></td>
                        <td align="left" style="color: #267cb7;" class="content" data-value="<%#Eval("id") %>">发送消息</td>
                    </tr>
                </ItemTemplate>
                <FooterTemplate>
                    <%#rptList.Items.Count == 0 ? "<tr><td align=\"center\" colspan=\"20\">暂无记录</td></tr>" : ""%>
          </table>
                </FooterTemplate>
            </asp:Repeater>
        </div>
        <!--/列表-->
    </form>
    <script>
        $(".content").each(function () {
            var username = $(this).attr("data-value");
            $(this).click(function () {
                var winDialog = top.dialog({
                    title: '发送内容',
                    content: '<textarea id="txtContent" name="txtContent" rows="2" cols="20" class="input"></textarea>',
                    okValue: '确定',
                    ok: function () {
                        var content = $("#txtContent", parent.document).val();
                        var postData = { "users": username, "content": content };
                        sendAjaxUrl(winDialog, postData);
                        return false;
                    },
                    cancelValue: '取消',
                    cancel: function () { }
                }).showModal();
            });
        });
        function sendAjaxUrl(winObj, postData) {
            $.ajax({
                type: "post",
                url: "../../tools/admin_ajax.ashx?action=huanxin_sends&type=chatrooms",
                data: postData,
                dataType: "json",
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    top.dialog({
                        title: '提示',
                        content: '尝试发送失败，错误信息：' + errorThrown,
                        okValue: '确定',
                        ok: function () { }
                    }).showModal(winObj);
                },
                success: function (data, textStatus) {
                    if (data.status == 0) {
                        winObj.close().remove();
                        var d = dialog({ content: data.msg }).show();
                        setTimeout(function () { d.close().remove(); location.reload(); }, 2000);
                    } else {
                        top.dialog({
                            title: '提示',
                            content: '错误提示：' + data.msg,
                            okValue: '确定',
                            ok: function () { }
                        }).showModal(winObj);
                    }
                }
            });
        }
    </script>
</body>
</html>
